#ifndef DESKTIDYWND_H
#define DESKTIDYWND_H

class DeskTidyWnd;

#include "common.h"
#include "resource.h"
#include "CassiopeiaMain.h"


#define DESKTIDYWND_MENUFIRSTID					0x0030

#define MENUOPEN				      			DESKTIDYWND_MENUFIRSTID
#define MENUNEW   								DESKTIDYWND_MENUFIRSTID + 1
#define MENUREMOVE       						DESKTIDYWND_MENUFIRSTID + 2
#define MENUPROPERTIES							DESKTIDYWND_MENUFIRSTID + 3
#define MENUREFRESH								DESKTIDYWND_MENUFIRSTID + 4
#define MENULOCK				      			DESKTIDYWND_MENUFIRSTID + 5


class DeskTidyWnd : public CustomWindow
{
public:
	typedef void (*DTWNDEVENTPROC)(DeskTidyWnd* sender);

	DeskTidyWnd(DTWNDEVENTPROC ptr, int id, bool removable = true);
	~DeskTidyWnd();
	void Create(HINSTANCE hInstance, LPCTSTR text, RECT bounds);
		
	void ShowPageButtons(bool prevPage, bool nextPage);
	int GetCurrentPage();
	void SetCurrentPage(int page);
	int GetId();
	void SetSwitchToPrevPagePtr(DTWNDEVENTPROC ptr);
	void SetSwitchToNextPagePtr(DTWNDEVENTPROC ptr);
	void SetOnRefreshPtr(DTWNDEVENTPROC ptr);
	void SetOnLockChangedPtr(DTWNDEVENTPROC ptr);
	void SetOnNewClickedPtr(DTWNDEVENTPROC ptr);
	void SetOnRemoveClickedPtr(DTWNDEVENTPROC ptr);
	void SetOnPropertiesClickedPtr(DTWNDEVENTPROC ptr);
	void SetBounds(RECT value);
	void SetBounds(LONG left, LONG top, LONG right, LONG bottom);
	void SetSize(SIZE value);
	void SetSize(LONG cx, LONG cy);
	bool GetLocked();
	void SetLocked(bool value);
	bool GetActive();
	void SetActive(bool value);
	void SetManipulateOptionsDisabled(bool value);


	static int Height;
private:	
	void SetDwmCompatibleWindowProperties(BOOL dwmEnabled);

	int roundCorner;
	int id;
	bool active;
	bool locked;
	bool removable;
	int currentPage;

	PaintedButton* buttonNextPage;
	PaintedButton* buttonPrevPage;

	HMENU systemMenu;
	DTWNDEVENTPROC onActiveChangedPtr;
	DTWNDEVENTPROC onRefreshPtr;
	DTWNDEVENTPROC onLockChangedPtr;
	DTWNDEVENTPROC onNewClickedPtr;
	DTWNDEVENTPROC onRemoveClickedPtr;
	DTWNDEVENTPROC onPropertiesClickedPtr;
	DTWNDEVENTPROC onSwitchToNextPagePtr;
	DTWNDEVENTPROC onSwitchToPrevPagePtr;

	static HWND GetLastWindowExcludingDTWnd();
	static void ToggleActiveState(HWND hWnd);
	static RECT DockDTWnd(HWND hWnd, HWND movedHWnd);
	static void CallDTWndEvent(DTWNDEVENTPROC ptr, DeskTidyWnd* sender);

	static void buttonNextPage_Clicked(PaintedButton* sender, LPVOID tag);
	static void buttonPrevPage_Clicked(PaintedButton* sender, LPVOID tag);
	static LRESULT CALLBACK WndProc(LPVOID sender, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
};

#endif
